package jm.nj.day08jia.demo04;
/*
* 获取功能
*       int length()   //获取字符串长度
*       char charAt(int index)  获取指定索引值字符
*       int  indexOf(String str)        //获取字符串str第一次出现的索引值,如果没有找到,返回-1
*       String substring(int strat)     //从指定strat索引值开始,到字符串结束
*       String substring(int strat,int end)     //从strat开始   到end结束
*
*
* */
public class Test01 {
    public static void main(String[] args) {
        String s = "hello";

        System.out.println("s.length() = "+s.length() );

        System.out.println("=============");

        System.out.println(s.charAt(0));//h
        System.out.println(s.charAt(3));//l

        System.out.println("==============");

        System.out.println(s.indexOf("h"));//0
        System.out.println(s.indexOf("o"));//4
        System.out.println(s.indexOf("he"));//0
        System.out.println(s.indexOf("el"));//1
        System.out.println(s.indexOf("ele"));//-1

        System.out.println("==========");

        String s2 = "helloworld";
        System.out.println("=============");

        System.out.println(s2.substring(3));//lowrld
        System.out.println(s2.substring(1));//elloworld

        String s3 = s2.substring(2);
        System.out.println(s3);//lloworld
        System.out.println("==========");

        System.out.println(s2.substring(0,2));//hel
        System.out.println(s2.substring(2,3));//l
    }
}
